﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>salary_standard_details</title>
    <script src="~/lib/echarts/echarts.js"></script>
    <script src="~/lib/axios/dist/axios.js"></script>
    <script src="~/lib/vue/dist/vue.js"></script>
    <script src="~/lib/element-ui/lib/index.js"></script>
    <link href="~/lib/element-ui/lib/theme-chalk/index.css" rel="stylesheet" />
</head>
<body>
    <div id="app">
        <el-container>
            <el-header>
                <el-card class="box-card">
                    <el-col :span="4"> 薪酬标准登记复核 </el-col>
                </el-card>
            </el-header>
            <el-main>
                <el-card class="box-card">
                    <el-form ref="form"
                             :model="form"
                             :rules="formrule"
                             :inline="true"
                             label-width="80px"
                             size="mini">
                        <el-row>
                            <el-form-item class="_klpo">
                                <template>
                                    <el-button type="primary" @@click="submitForm('form')">复核通过</el-button>
                                </template>
                                <el-button @@click="eas()">返回</el-button>
                            </el-form-item>
                        </el-row>
                        <el-form-item label="薪酬标准编号" prop="standard_id" label-width="96px">
                            <el-input v-model="form.standard_id" style="width: 148px" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="薪酬标准名称" prop="standard_name" label-width="107px">
                            <el-input v-model="form.standard_name" style="width: 210px" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="薪酬总额" prop="salary_sum">
                            <el-input v-model="form.salary_sum" style="width: 162px" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="制定人" prop="designer" label-width="65px">
                            <template>
                                <el-select v-model="form.designer" placeholder="请选择登记人" style="width: 200px " :disabled="true">
                                    <el-option v-for="item in listm"
                                               :key="item.u_id"
                                               :label="item.u_true_name"
                                               :value="item.u_true_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item label="复核人" prop="checker" label-width="65px">
                            <template>
                                <el-select v-model="form.checker" placeholder="请选择登记人" style="width: 180px ">
                                    <el-option v-for="item in listm"
                                               :key="item.u_id"
                                               :label="item.u_true_name"
                                               :value="item.u_true_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item prop="check_time" label="复核时间" label-width="96px">
                            <el-date-picker style="width: 220px " :disabled="true" type="datetime" placeholder="选择日期" v-model="form.check_time"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="复核意见" prop="check_comment" label-width="68px">
                            <el-input type="textarea" v-model="form.check_comment" style="width: 1044px " autosize></el-input>
                        </el-form-item>
                        <div ref="main" style="width: 600px; height: 250px;"></div>
                        <div ref="main1" style="width: 600px; height: 250px; margin: auto; float: right; top: -220px; position: relative; "></div>
                    </el-form>
                </el-card>
            </el-main>
        </el-container>

    </div>
    <script type="text/javascript">
        var vm = new Vue({
            el: "#app",
            data: {
                listm:[],//用户
                form: {
                    standard_id: '',
                    standard_name: '',
                    designer: '',
                    salary_sum: '',
                    checker:'',
                    check_time: '',
                    check_comment:'',
                },
                formrule: {
                    checker: [
                        { required: true, message: '请选择复核人', trigger: 'change' }
                    ],
                }
            },
            methods: {
                eas() {
                    location.href = "/salary_standardTo/salary_standardTo";
                },
                submitForm(formName) {
                    //表单验证
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            this.$confirm('此操作将此薪酬信息通过, 是否通过?', '提示', {
                                    confirmButtonText: '确定',
                                    cancelButtonText: '取消',
                                    type: 'warning'
                            }).then(() => {
                                      //薪酬复核通过修改
                                    axios.get('/salary_standardTo/Updateou', {
                                        params: {
                                            ssd_id:@ViewBag.ssd_id,
                                            checker: this.form.checker,
                                            check_time: this.form.check_time,
                                            check_comment: this.form.check_comment,
                                        }
                                    })
                                        .then(res => {
                                            console.info(res);
                                            this.$message({
                                                type: 'success',
                                                message: '通过成功!'
                                            });
                                            this.eas();
                                        })
                                        .catch(err => {
                                            console.info(err);
                                        });
                                }).catch(() => {
                                    this.$message({
                                        type: 'info',
                                        message: '已取消通过'
                                    });
                                });
                        } else {
                            this.$message({
                                type: 'error',
                                message: '请填写完整信息!'
                            });
                            return false;
                        }
                    });
                },
                fill() {
                    //用户查询
                    axios.get('/users/que', {
                    })
                        .then(res => {
                            console.info(res);
                            this.listm = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //薪酬查询
                    axios.get('/salary_standardTo/Chui/'+@ViewBag.ssd_id)
                        .then(res => {
                            console.info(res);
                            this.form.standard_id = res.data.standard_id;
                            this.form.standard_name = res.data.standard_name;
                            this.form.designer = res.data.designer;
                            this.form.salary_sum = res.data.salary_sum;
                             //薪酬详细数据表查询
                            axios.get('/salary_standardTo/ChuiTo', {
                                params: {
                                    id: res.data.standard_id,
                                }
                            })
                                .then(res => {
                                    console.info(res);
                                    // 基于准备好的dom，初始化echarts实例
                                    var myChart = echarts.init(this.$refs.main);
                                    var pid = [];
                                    for (var index in res.data) {
                                        var obj = {
                                            value: res.data[index].salary,
                                            name: res.data[index].item_name
                                        };
                                        pid.push(obj);
                                    }
                                    // 指定图表的配置项和数据
                                    var option = {
                                        title: {
                                            text: '薪酬详细信息表',
                                            subtext: '',
                                            left: 'center'
                                        },
                                        tooltip: {
                                            trigger: 'item'
                                        },
                                        legend: {
                                            orient: 'vertical',
                                            left: 'left'
                                        },
                                        series: [
                                            {
                                                name: 'Access From',
                                                type: 'pie',
                                                radius: '65%',
                                                data: pid,
                                                emphasis: {
                                                    itemStyle: {
                                                        shadowBlur: 10,
                                                        shadowOffsetX: 0,
                                                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                                                    }
                                                }
                                            }
                                        ]
                                    };

                                    // 使用刚指定的配置项和数据显示图表。
                                    myChart.setOption(option);

                                    // 基于准备好的dom，初始化echarts实例
                                    var myChart1 = echarts.init(this.$refs.main1);
                                    var pid1 = [];
                                    var pids1 = [];
                                    for (var index in res.data) {
                                        pid1.push(res.data[index].item_name);
                                        pids1.push(res.data[index].salary);
                                    }
                                    // 指定图表的配置项和数据
                                    var option1 = {
                                        xAxis: {
                                            type: 'category',
                                            data: pid1
                                        },
                                        yAxis: {
                                            type: 'value'
                                        },
                                        series: [
                                            {
                                                name: 'Life Cost',
                                                type: 'bar',
                                                stack: 'Total',
                                                label: {
                                                    show: true,
                                                    position: 'inside'
                                                },
                                                data: pids1
                                            }
                                        ]
                                    };

                                    // 使用刚指定的配置项和数据显示图表。
                                    myChart1.setOption(option1);
                                })
                                .catch(err => {
                                    console.info(err);
                                });
                        })
                        .catch(err => {
                            console.info(err);
                        });
                },
                get() {
                    //当前时间
                    this.form.check_time = new Date();
                },
            },
            //可以对vue的数据和方法进行操作也能对DOM进行操作
            mounted: function () {
                //时间计时器
                setInterval(this.get, 1000);
                this.fill();
            }
        });
    </script>
    <style>
        .el-col-4 {
            width: 20%;
            font-size: 15px;
            font-weight: 900;
            line-height: 0px;
        }
        .el-card__body {
            padding: 35px;
        }
        element.style {
            height: 100%;
            width: 1239px;
        }

        .el-button.is-circle {
            border-radius: 50%;
            padding: 12px;
            position: relative;
            top: -10px;
            right: -570px;
        }

        ._klpo {
            float: right;
        }
    </style>
</body>
</html>
